<template>
  <a-select ref="selectRef" :default-open="autoFocus" :autofocus="autoFocus">
    <slot></slot>
  </a-select>
</template>

<script setup>
/**
 * @name 基础选择组件
 *
 */
import { ref, watch } from 'vue'

const props = defineProps({
  autoFocus: {
    type: Boolean,
    default: false
  }
})
const selectRef = ref(null)
watch(
  () => props.autoFocus,
  (value) => {
    value && setTimeout(() => selectRef.value.focus(), 1)
  },
  { immediate: true }
)
</script>
